home *** CD-ROM | disk | FTP | other *** search
/ Unreal Tournament Game Programming for Teens / UnrealTournamentGameProgrammingForTeens.iso / Chapter Files / Chapter10 / UT2004 / Ch09Disco / Classes / DiscoBallB.uc < prev    next >
Encoding:
Text File  |  2006-10-29  |  2.0 KB  |  94 lines

  1. //======================================================================
  2. // DiscoBallB
  3. // DiscoBallB.txt
  4. //======================================================================
  5. //#1
  6. class DiscoBallB extends KActor placeable;
  7. var private int Next;
  8. var private float TimerD;
  9. enum SIDES{
  10.       TOP,
  11.       LEFT,
  12.       BOTTOM,
  13.       RIGHT
  14. };
  15. const PATHS = 4;
  16. var Vector Square[PATHS]; 
  17.  
  18. // #2
  19. function PreBeginPlay() {
  20.     //Called once to set initial values 
  21.  
  22.     SetTimeD(6.0);   
  23.     //From the KActor class
  24.     SetTimer(TimerD, true);
  25.     //Set for this class 
  26.     Next = 0;
  27.     
  28. }
  29.  
  30. // #3
  31. private function CreatePaths(){
  32.    Square[SIDES.TOP]  =    vect(40.0  ,0,      0);
  33.    Square[SIDES.LEFT] =    vect(0,     0,  -40.0);
  34.    Square[SIDES.BOTTOM]  = vect(-40.0 ,0,      0);
  35.    Square[SIDES.RIGHT] =   vect(0,     0,   40.0);
  36. }
  37.  
  38. //Accessor for the array
  39. private function Vector GetPath(SIDES path){
  40.   return Square[path];
  41. }
  42.  
  43.  
  44. function PostBeginPlay() {
  45.     Velocity = vect(0 , 0, 0);
  46.      CreatePaths();
  47. }
  48.  
  49. // #4
  50. function Timer() {
  51.      ChangePath();
  52. }
  53.  
  54. // #5
  55. //Sets initial values for the time durations
  56. //Call once to set the inital state of the class
  57. private function SetTimeD(float dur){
  58.       if(dur < 0){
  59.          dur = 0;
  60.       }
  61.       TimerD = dur;
  62. }
  63.  
  64.  
  65. // #6
  66. //Creates a "square" path for the object
  67. private function ChangePath(){
  68.  if(Next == SIDES.TOP){
  69.        //positive x direction
  70.        Velocity = GetPath(SIDES.TOP);
  71.        Next++;
  72.     }else if(Next == SIDES.LEFT){
  73.        // Negative z direction
  74.        Velocity = GetPath(SIDES.LEFT);
  75.        Next++;
  76.        }else if(Next == SIDES.BOTTOM){
  77.        // Negative x direction 
  78.        Velocity = GetPath(SIDES.BOTTOM);
  79.        Next++;
  80.     }else if (Next == SIDES.RIGHT){
  81.        //posivite  z direction
  82.        Velocity = GetPath(SIDES.RIGHT);
  83.        Next = SIDES.TOP;
  84.     }else{
  85.  
  86.        Next = SIDES.TOP;
  87.     }
  88. }
  89.  
  90. defaultproperties
  91. {
  92.      StaticMesh=Ch09Disco.Disco.Discoball
  93. }
  94.